import Vue from "vue";
import App from "./App.vue";

// 引入移动端布局插件
// 将当前屏幕尺寸 除以10的值设置为html标签的font-size 的大小
import "amfe-flexible";
// 引入重置样式
import "@/assets/css/reset.css";

// 引入less css预编译处理(因为全局都要使用,所以在main.js引入)
import less from "less";
Vue.use(less);

// 引入vant ui 组件库(全部导入)
// import Vant from 'vant'
// import 'vant/lib/index.css'
// Vue.use(Vant)
import {
  Lazyload,
  Loading,
  Icon,
  Toast,
  search,
  grid,
  List,
  Swipe,
  SwipeItem,
  Grid,
  GridItem,
  Tabbar,
  TabbarItem,
  pagination,
  sidebar,
  sidebarItem,
  divider,
  checkbox,
  checkboxGroup,
  SubmitBar,
  Card,
  button,
  overlay,
  Form,
  field,
  dropdownMenu,
  dropdownItem,
  Dialog,
  goodsAction,
  goodsActionButton,
  goodsActionIcon,
  sku,
  Tab,
  Tabs,
} from "vant";
Vue.use(Loading);
Vue.use(Grid);
Vue.use(GridItem);
Vue.use(Lazyload);
Vue.use(Icon);
Vue.use(Toast);
Vue.use(search);
Vue.use(Swipe);
Vue.use(grid);
Vue.use(Tabbar);
Vue.use(TabbarItem);
Vue.use(List);
Vue.use(SwipeItem);
Vue.use(pagination);
Vue.use(sidebar);
Vue.use(sidebarItem);
Vue.use(divider);
Vue.use(checkbox);
Vue.use(checkboxGroup);
Vue.use(SubmitBar);
Vue.use(Card);
Vue.use(button);
Vue.use(overlay);
Vue.use(Form);
Vue.use(field);
Vue.use(dropdownMenu);
Vue.use(dropdownItem);
Vue.use(Dialog);
Vue.use(goodsAction);
Vue.use(goodsActionButton);
Vue.use(goodsActionIcon);
Vue.use(sku);
Vue.use(Tab);
Vue.use(Tabs);

// import loading from '@/assets/img/loading.gif'
// 注册时可以配置额外的选项
Vue.use(Lazyload, {
  lazyComponent: true,
  loading: "@/assets/img/loading.gif",
});

//引入路由
import router from "@/router";

// 定义全局过滤器
Vue.filter("formatMoney", (val) => {
  return `￥${val.toFixed(2)}元`;
});
Vue.filter("text", (val) => {
  if (val) {
    return `￥${val.toFixed(2)}元起`;
  } else {
    return "起";
  }
});

Vue.prototype.bus = new Vue();

new Vue({
  render: (h) => h(App),
  router,
}).$mount("#app");
